The Command window is used to execute commands or aliases directly in the Visual Studio integrated development environment (IDE). You can execute both menu commands and commands that do not appear on any menu. To display the Command window, choose Other Windows from the View menu, and select Command Window.
To check the value of a variable varA
, use the Print Command:
>Debug.Print varA
The question mark (?) is an alias for Debug.Print
, so this command can also be written:
>? varA
Both versions of this command will return the value of the variable varA
.
The greater than symbol (>
) appears at the left edge of the Command window as a prompt for new lines. Use the UP ARROW and DOWN ARROW keys to scroll through previously issued commands.
Task | Solution | Example |
---|---|---|
Evaluate an expression. | Preface the expression with a question mark (? ). |
? myvar |
Switch to an Immediate window. | Enter immed into the window without the greater than sign (>) |
immed |
Switch back to the Command window from an Immediate window. | Enter cmd into the window. |
>cmd |
The following shortcuts help you navigate while in Command mode.
Action | Cursor location | Keybinding |
---|---|---|
Cycle through the list of previously entered commands. | Input line | UP ARROW & DOWN ARROW |
Scroll up the window. | Command window contents | CTRL+UP ARROW |
Scroll down the window. | Command window contents | DOWN ARROW or CTRL+DOWN ARROW |
Tip
You can copy all or part of a previous command to the input line by scrolling to it, highlighting all or part of it, and then pressing ENTER.
When you click on any previous line in the Command window, you shift automatically into Mark mode. This allows you to select, edit, and copy the text of previous commands as you would in any text editor, and paste them into the current line.
The window used to enter the EvaluateStatement
command determines whether an equals sign (=) is interpreted as a comparison operator or as an assignment operator.
In the Command window, an equals sign (=) is interpreted as a comparison operator. You cannot use assignment operators in the Command window. So, for example, if the values of variables varA
and varB
are different, then the command >Debug.EvaluateStatement(varA=varB)
will return a value of False
.
In the Immediate window, by contrast, an equals sign (=) is interpreted as an assignment operator. So, for example, the command >Debug.EvaluateStatement(varA=varB)
will assign to variable varA
the value of variable varB
.
Some Visual Studio commands have required and optional arguments, switches and values. Certain rules apply when dealing with such commands. The following is an example of a rich command to clarify the terminology.
Edit.ReplaceInFiles /case /pattern:regex var[1-3]+ oldpar
In this example,
Edit.ReplaceInFiles
is the command
/case
and /pattern:regex
are switches (prefaced with the slash [/] character)
regex
is the value of the /pattern
switch; the /case
switch has no value
var[1-3]+
and oldpar
are parameters
Note
Any command, parameter, switch, or value that contains spaces must have double quotation marks on either side.
The position of switches and parameters can be interchanged freely on the command line with the exception of the Shell command, which requires its switches and parameters in a specific order.
Nearly every switch supported by a command has two forms: a short (one character) form and a long form. Multiple short-form switches can be combined into a group. For example, /p /g /m
can be expressed alternately as /pgm
.
If short-form switches are combined into a group and given a value, that value applies to every switch. For example, /pgm:123
equates to /p:123 /g:123 /m:123
. An error occurs if any of the switches in the group does not accept a value.
A caret (^) character in a command line means that the character immediately following it is interpreted literally, rather than as a control character. This can be used to embed straight quotation marks ("), spaces, leading slashes, carets, or any other literal characters in a parameter or switch value, with the exception of switch names. For example,
>Edit.Find ^^t /regex
A caret functions the same whether it is inside or outside quotation marks. If a caret is the last character on the line, it is ignored. The example shown here demonstrates how to search for the pattern "^t".
If, for example, you want to open a file that has a path containing spaces, you must put double quotes around the path or path segment that contains spaces: C:\"Program Files" or "C:\Program Files".
Visual Studio commands allow you to invoke a command from the Command window, Immediate window, or Find/Command box. In each case, the greater than sign (>
) is used to indicate that a command rather than a search or debug operation is to follow.
You can find a complete list of commands and their syntax in the Keyboard, Environment Options dialog box.
The escape character for Visual Studio commands is a caret (^) character, which means that the character immediately following it is interpreted literally, rather than as a control character. This can be used to embed straight quotation marks ("), spaces, leading slashes, carets, or any other literal characters in a parameter or switch value, with the exception of switch names. For example,
>Edit.Find ^^t /regex
A caret functions the same whether it is inside or outside quotation marks. If a caret is the last character on the line, it is ignored.
In localized versions of the IDE, command names can be entered either in the native language of the IDE or in English. For example, you can type either File.NewFile
or Fichier.NouveauFichier
in the French IDE to execute the same command.
Many commands have aliases. For a list of command aliases, see Visual Studio Command Aliases.
The following commands take arguments and/or switches.
Command Name | Description |
---|---|
Add Existing Item | Adds an existing file to the current solution and opens it. |
Add Existing Project | Adds an existing project to the current solution. |
Add New Item | Adds a new solution item, such as an .htm, .css, .txt, or frameset to the current solution and opens it. |
Alias | Creates a new alias for a complete command, complete command and arguments, or even another alias. |
Evaluate Statement | Evaluates and displays the given statement. |
Find | Searches files using a subset of the options available on the Find and Replace control. |
Find in Files | Searches files using a subset of the options available on the Find in Files. |
Go To | Moves the cursor to the specified line. |
List Call Stack | Displays the current call stack. |
List Disassembly | Begins the debug process and allows you to specify how errors are handled. |
List Memory | Displays the contents of the specified range of memory. |
List Modules | Lists the modules for the current process. |
List Registers | Displays a list of registers. |
List Source | Displays the specified lines of source code. |
List Threads | Displays a list of the threads in the current program. |
Log Command Window Output | Copies all input and output from the Command window into a file. |
New File | Creates a new file and adds it to the currently selected project. |
Open File | Opens an existing file and allows you to specify an editor. |
Open Project | Opens an existing project and allows you to add the project to the current solution. |
Evaluates the expression and displays the results or the specified text. | |
Quick Watch Command | Displays the selected or specified text in the Expression field of the Quick Watch dialog box. |
Replace | Replaces text in files using a subset of the options available on the Find and Replace control. |
Replace in Files | Replaces text in files using a subset of the options available in the Replace in Files. |
Set Current Stack Frame | Allows you to view a particular stack frame. |
Set Current Thread | Allows you to view a particular thread. |
Set Radix | Determines the number of bytes to view. |
Shell | Launches programs from within Visual Studio as though the command has been executed from the command prompt. |
ShowWebBrowser Command | Displays the URL you specify in a web browser window either within the integrated development environment (IDE) or external to the IDE. |
Start | Begins the debug process and allows you to specify how errors are handled. |
Path | Sets the list of directories for the debugger to search for symbols. |
Toggle Breakpoint | Turns the breakpoint either on or off, depending on its current state, at the current location in the file. |
Watch Command | Creates and opens a specified instance of a Watch window. |
Command aliases let you type fewer characters when you want to execute a command. You enter aliases into the Find/Command box or Command window. For example, instead of entering >File.OpenFile
to display the Open File dialog box, you can use the pre-defined alias >of
.
Type alias
in the Command window to display a list of the current aliases and their definitions. Type >cls
to clear the contents of the Command window. If you want to see an alias for a specific command, type alias <command name>
.
You can easily create your own alias for one of the Visual Studio commands (with or without arguments). For example, the syntax for aliasing File.NewFile MyFile.txt
is alias MyAlias File.NewFile MyFile.txt
. You can delete one of your aliases with alias <alias name> /delete
The table below contains a list of the pre-defined Visual Studio command aliases. Some command names have more than one pre-defined alias. Click the links for the command names below to display detailed topics that explain the correct syntax, arguments, and switches for those commands.
Command Name | Alias | Complete Name |
---|---|---|
Print Command | ? | Debug.Print |
Quick Watch Command | ?? | Debug.Quickwatch |
Add New Project | AddProj | File.AddNewProject |
Alias Command | Alias | Tools.Alias |
Autos window | Autos | Debug.Autos |
Breakpoints window | bl | Debug.Breakpoints |
Toggle Breakpoint | bp | Debug.ToggleBreakPoint |
Call Stack window | CallStack | Debug.CallStack |
Clear Bookmarks | ClearBook | Edit.ClearBookmarks |
Close | Close | File.Close |
Close All Documents | CloseAll | Window.CloseAllDocuments |
Clear All | cls | Edit.ClearAll |
Command mode | cmd | View.CommandWindow |
View Code | code | View.ViewCode |
List Memory Command | d | Debug.ListMemory |
List Memory Command as ANSI | da | Debug.ListMemory /Ansi |
List Memory Command One-Byte format | db | Debug.ListMemory /Format:OneByte |
List Memory Command as ANSI with Four-Byte format | dc | Debug.ListMemory /Format:FourBytes /Ansi |
List Memory Command Four-Byte format | dd | Debug.ListMemory /Format:FourBytes |
Delete to BOL | DelBOL | Edit.DeleteToBOL |
Delete to EOL | DelEOL | Edit.DeleteToEOL |
Delete Horizontal Whitespace | DelHSp | Edit.DeleteHorizontalWhitespace |
View Designer | designer | View.ViewDesigner |
List Memory Command Float format | df | Debug.ListMemory/Format:Float |
Disassembly window | disasm | Debug.Disassembly |
List Memory Command Eight-Byte format | dq | Debug.ListMemory /Format:EightBytes |
List Memory Command as Unicode | du | Debug.ListMemory /Unicode |
Evaluate Statement Command | eval | Debug.EvaluateStatement |
Exit | Exit | File.Exit |
Format Selection | format | Edit.FormatSelection |
Full Screen | FullScreen | View.FullScreen |
Start Command | g | Debug.Start |
Go To Command | GotoLn | Edit.GoTo |
Go to Brace | GotoBrace | Edit.GotoBrace |
F1Help | Help | Help.F1Help |
Immediate Mode | immed | Tools.ImmediateMode |
Insert File as Text | InsertFile | Edit.InsertFileAsText |
List Call Stack Command | kb | Debug.ListCallStack |
Make Lower Case | Lcase | Edit.MakeLowercase |
Cut Line | LineCut | Edit.LineCut |
Delete Line | LineDel | Edit.LineDelete |
List Members | ListMembers | Edit.ListMembers |
Locals window | Locals | Debug.Locals |
Log Command Window Output Command | Log | Tools.LogCommandWindowOutput |
Command Window Mark Mode | mark | Tools.CommandWindowMarkMode |
Memory window | Memory Memory1 | Debug.Memory1 |
Memory Window 2 | Memory2 | Debug.Memory2 |
Memory Window 3 | Memory3 | Debug.Memory3 |
Memory Window 4 | Memory4 | Debug.Memory4 |
Set Radix Command | n | Debug.SetRadix |
ShowWebBrowser Command | nav navigate | View.ShowWebBrowser |
Next Bookmark | NextBook | Edit.NextBookmark |
New File Command | nf | File.NewFile |
New Project | np NewProj | File.NewProject |
Open File Command | of Open | File.OpenFile |
Open Project Command | op | File.OpenProject |
Collapse to Definitions/Stop Outlining | OutlineDefs StopOutlining | Edit.CollapseToDefinitions |
Step Over | p | Debug.StepOver |
Parameter Information | ParamInfo | Edit.ParameterInfo |
Step Out | pr | Debug.StepOut |
Previous Bookmark | PrevBook | Edit.PreviousBookmark |
Print File | File.Print | |
Properties Window | props | View.PropertiesWindow |
Stop | q | Debug.StopDebugging |
Redo | redo | Edit.Redo |
Registers window | registers | Debug.Registers |
Run to Cursor | rtc | Debug.RunToCursor |
Save Selected Items | save | File.SaveSelectedItems |
Save All | SaveAll | File.SaveAll |
Save As | SaveAs | File.SaveSelectedItemsAs |
Shell Command | shell | Tools.Shell |
Stop Find In Files | StopFind | Edit.FindInFiles /stop |
Swap Anchor | SwapAnchor | Edit.SwapAnchor |
Step Into | t | Debug.StepInto |
Tabify Selection | tabify | Edit.TabifySelection |
Tasklist window | TaskList | View.TaskList |
Threads window | Threads | Debug.Threads |
Tile Horizontally | TileH | Window.TileHorizontally |
Tile Vertically | TileV | Window.TileVertically |
Toggle Bookmark | ToggleBook | Edit.ToggleBookmark |
Toolbox window | toolbox | View.Toolbox |
List Disassembly Command | u | Debug.ListDisassembly |
Make Uppercase | Ucase | Edit.MakeUppercase |
Undo | undo | Edit.Undo |
Untabify Selection | Untabify | Edit.UntabifySelection |
Watch window | Watch | Debug.WatchN |
Toggle Word Wrap | WordWrap | Edit.ToggleWordWrap |
List Processes | | | Debug.ListProcesses |
List Threads Command | ~ ~*k ~*kb | Debug.ListThreads Debug.ListTheads /AllThreads |